/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package base;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author Tue
 */
public class KNNode {
    private String name;
    private ArrayList<KNLink> linkTable;
    private Hashtable<Integer, Hashtable<String, Vector>> colorTable;
    private String NATIndex;
    public KNNode(String name){
        this.name = name;
        linkTable = new ArrayList();
        colorTable = new Hashtable<Integer, Hashtable<String, Vector>>();
    }
    public String getName(){
        return this.name;
    }

    public ArrayList<KNLink> getAllLinks(){
        return (ArrayList<KNLink>)linkTable;
    }
    public ArrayList<KNLink> getLinks(int sign){
        ArrayList<KNLink> result = new ArrayList<KNLink>();
        ArrayList<KNLink> allLink=(ArrayList<KNLink>)linkTable;
        for(KNLink link : allLink){
            if(link.getSign() == sign)
                result.add(link);
        }
        return result;
    }
    public Hashtable<String, Vector> getNodalTable(int color){
        if(this.colorTable.get(color) == null) {
            Hashtable<String, Vector> nodalTable = new Hashtable<String, Vector>();
            this.colorTable.put(color, nodalTable );
            return nodalTable;
        }
        return this.colorTable.get(color);
    }
    public void addLink(KNLink link){
        linkTable.add(link);
    }
    public void setNATIndex(String index){
        this.NATIndex = index;
    }
    public void removeAllLinks(){
        linkTable.clear();
    }
    @Override
    public String toString() {
        return this.name + "|" + this.linkTable;
    }

}
